package com.dong.rabbitmq.deadqueue;

import com.dong.rabbitmq.utils.RabbitMqUtil;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dongjian
 * 死信队列-消费者02 只消费死信队列的消息
 */
public class Consumer02 {

    /**
     * 死信队列
     */
    public static final String DEAD_QUEUE = "dead_queue";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtil.getChannel();
        System.out.println("Consumer02等待接收消息......");
        // 消息处理
        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println("Consumer02接收消息是：" + new String(message.getBody(), "UTF-8"));
        };
        // 接收消息
        channel.basicConsume(DEAD_QUEUE, true, deliverCallback, consumerTag -> {
        });

    }
}
